package 牛客.百度.最小公约数域最大公倍数;

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        if(i==2){
            System.out.println(0);
        }
        int max = 0;
        for(int ii=1;ii<i;ii++){
            int a = imc(ii,i)-gcd(ii,i);
            max = max>a?max:a;
        }
        System.out.println(max);
    }

    private static int imc(int i, int i1) {//最小公倍数
        int a = 0;
        a = i*i1;
        a = a/gcd(i,i1);
        return a;
    }

    private static int gcd(int i, int i1) {//最大公约数
        int a = 1;
        if(i>i1){
            a = i;
            i = i1;
            i1 = a;
        }
        while (a!=0){
            a = i%i1;
            i = i1;
            i1 = a;
        }
        return i;
    }

}
